import string
from enum import Enum
import json
from flask import jsonify




class Status(Enum):
    SUCCESS = 0
    FAILURE = 1
    ILLEGAL = 2
    NEEDLOGIN = 10
    VARERROR = 401
    NONEPRI = 403


class CommonResponse:

    @staticmethod
    def requestSuccess(data):
        data = data
        status = json.dumps(Status.SUCCESS.value)
        from utils.EnumEncoder import EnumEncoder
        print(type(status))
        message = json.dumps(Status.SUCCESS,cls=EnumEncoder)
        print(type(message))

        return jsonify({
            "status": status,
            "message": message,
            "data": data
        })

    @staticmethod
    def requestSuccessAndMessage(data,message):

        status = json.dumps(Status.SUCCESS.value)
        return jsonify({
            "status": status,
            "message": message,
            "data": data
        })

    @staticmethod
    def requestSuccessMessage(message):
        status = Status.SUCCESS.value
        message = message

        return jsonify({
            "status": status,
            "message": message,
        })

    @staticmethod
    def requestFailureMessage(message):
        status = Status.FAILURE.value
        message = message

        return jsonify({
            "status": status,
            "message": message,
        })

    @staticmethod
    def requestFailureStatusAndMessage(nowstatus, message):
        status = nowstatus
        message = message

        return jsonify({
            "status": status,
            "message": message,
        })
